package com.vijay.exam.controller;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.vijay.exam.PaperDAO;

@Controller
public class PaperController {
	private static final Logger logger = LoggerFactory.getLogger(PaperController.class);

	@Autowired
	PaperDAO paperDAO;
	
	/**
	 * Simply selects the home view to render by returning its name.
	 */
	@RequestMapping(value="/paper", method=RequestMethod.GET)
	public String paperChoice() {
		logger.info("paperChoice");
		
		Session session=paperDAO.getSessionFactory().openSession();
		Transaction txn=session.beginTransaction();
		List<String> paperLst = paperDAO.findDistinctPaper();
		for(String p: paperLst){
			System.out.println(p);
		}
		
		//txn.commit();
		
		return "paper";
	}
}
